home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Libraries / TurboTCP 2.0.1 / TurboTCP source / CTCPSessionDoc.cp < prev    next >
Encoding:
Text File  |  1994-07-03  |  1.3 KB  |  66 lines  |  [TEXT/MPCC]

  1. /*
  2. ** CTCPSessionDoc.cp
  3. **
  4. **    TurboTCP support library
  5. **    TCP session document
  6. **
  7. **    Copyright © 1993-94, FrostByte Design / Eric Scouten
  8. **
  9. */
  10.  
  11.  
  12. #include "CTCPSessionDoc.h"
  13.  
  14.  
  15. // —— closing windows & sessions ——
  16.  
  17. /*______________________________________________________________________
  18. **
  19. ** Close
  20. **
  21. **    Respond to user close. Ensure that the TCP stream is gracefully closed. (This method is
  22. **    also called if the remote host closes the session or the session is terminated.)
  23. **
  24. **        quitting (Boolean):    TRUE if quitting
  25. **
  26. **        return (Boolean):    FALSE if close/quit aborted by user
  27. **
  28. */
  29.  
  30. Boolean CTCPSessionDoc::Close(Boolean quitting)
  31.  
  32. {
  33.     closeAndQuit = quitting;                        // do we really want to close?
  34.     if (!ConfirmClose(quitting))
  35.         return FALSE;
  36.  
  37.     if (itsFile)                                    // close file first
  38.         itsFile->Close();
  39.  
  40.     if (!LocalClose(quitting))                        // now close stream
  41.         return FALSE;
  42.  
  43.     return CDirector::Close(quitting);
  44.  
  45. }
  46.  
  47.  
  48. /*______________________________________________________________________
  49. **
  50. ** RemoteClose
  51. **
  52. **    Respond to notification that the remote host cancelled the session (either by normal
  53. **    close or terminate).
  54. **
  55. */
  56.  
  57. void CTCPSessionDoc::RemoteClose()
  58.  
  59. {
  60.     Boolean sessionWasEstablished = SessionEstablished();
  61.  
  62.     CTCPEndpoint::RemoteClose();
  63.     if ((goAwayOnClose) && (!sessionWasEstablished))
  64.         Close(FALSE);
  65. }
  66.